package com.hopes.bizz.poll.statistic.controller;


import com.hopes.bizz.poll.analy.dto.AnalyzeTrendDTO;
import com.hopes.bizz.poll.analy.dto.CompareAnalysisDTO;
import com.hopes.bizz.poll.analy.dto.CompareTrendDTO;
import com.hopes.bizz.poll.analy.dto.GISAnalyzeDischargeDTO;
import com.hopes.bizz.poll.analy.vo.CompareAnalysisVo;
import com.hopes.bizz.poll.statistic.service.DataTrendAnalyzeService;
import com.hopes.boss.common.core.util.R;
import com.hopes.boss.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yumr
 * @Description 数据趋势分析
 * @time 2023/5/29 19:05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/analysis")
@Tag(description = "analysisTrend", name = "数据趋势分析")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DataTrendAnalyzeController {

    private final DataTrendAnalyzeService dataTrendAnalyzeService;

    /**
     * 数据趋势分析
     *
     * @param analyzeTrendDTO 数据趋势分析参数
     * @return R
     */
    @Operation(summary = "数据趋势分析", description = "数据趋势分析")
    @SysLog("数据趋势分析")
    @PostMapping("/trend")
    @PreAuthorize("@pms.hasPermission('poll_trend_analyze_view')")
    public R listData(@RequestBody AnalyzeTrendDTO analyzeTrendDTO) {
        return R.ok(dataTrendAnalyzeService.listData(analyzeTrendDTO));
    }

    /**
     * GIS排放趋势
     *
     * @param gisAnalyzeDischargeDTO GIS排放趋势参数
     * @return R
     */
    @Operation(summary = "GIS排放趋势", description = "GIS排放趋势")
    @SysLog("GIS排放趋势")
    @PostMapping("/discharge")
    @PreAuthorize("@pms.hasPermission('poll_trend_discharge_view')")
    public R discharge(@RequestBody GISAnalyzeDischargeDTO gisAnalyzeDischargeDTO) {
        return R.ok(dataTrendAnalyzeService.gisAnalyzeDischarge(gisAnalyzeDischargeDTO));
    }


    @Operation(summary = "同比趋势分析", description = "同比趋势分析")
    @SysLog("同比趋势分析")
    @PostMapping("/compareTrend")
    @PreAuthorize("@pms.hasPermission('poll_compare_trend_analyze_view')")
    public R compareTrendAnalyze(@Validated @RequestBody CompareTrendDTO compareTrendDTO) {
        return R.ok(dataTrendAnalyzeService.compareTrendAnalyze(compareTrendDTO));
    }

    @Operation(summary = "数据同比分析", description = "数据同比分析")
    @SysLog("数据同比分析")
    @PostMapping("/compareAnalysis")
    public R compareAnalysis(@Validated @RequestBody CompareAnalysisDTO compareAnalysisDTO) {
        CompareAnalysisVo compareAnalysisVo = dataTrendAnalyzeService.compareAnalysis(compareAnalysisDTO);
        return R.ok(compareAnalysisVo);
    }

}
